#!/bin/bash

_major_version=@PROJECT_VERSION_MAJOR@
_minor_version=@PROJECT_VERSION_MINOR@
_patch_version=@PROJECT_VERSION_PATCH@

_version=v@PROJECT_VERSION@

_cc=@CMAKE_C_COMPILER@
_cxx=@CMAKE_CXX_COMPILER@
_fairsoft_path=@SIMPATH@

usage="\
Usage: fairroot-config [--version] [--major_version] [--minor_version] [--patch_version] \
[--cc] [--cxx] [--fairsoft_path] [--help]"

if [ $# -eq 0 -o $# -gt 1 ]; then
   echo "${usage}" 1>&2
   exit 1
fi

out=""


case $1 in
    --version)
      ### Output the fairroot version
      out="$out ${_version}"
      ;;
    --major_version)
      ### Output the fairroot version
      out="$out ${_major_version}"
      ;;
    --minor_version)
      ### Output the fairroot version
      out="$out ${_minor_version}"
      ;;
    --patch_version)
      ### Output the fairroot version
      out="$out ${_patch_version}"
      ;;
    --cc)
      ### Output the full path of used c compiler
      out="$out ${_cc}"
      ;;
    --cxx)
      ### Output the full path of used cxx compiler
      out="$out ${_cxx}"
      ;;
    --fairsoft_path)
      ### Output the full path to the used fairsoft installation
      out="$out ${_fairsoft_path}"
      ;;
    --help)
      ### Print a help message
      echo "Usage: `basename $0` [options]"
      echo ""
      echo "  --version            Print the fairroot version"
      echo "  --major_version      Print the fairroot major version"
      echo "  --minor_version      Print the fairroot minor version"
      echo "  --patch_version      Print the fairroot patch version"
      echo "  --cc                 Print the full path of the used c compiler"
      echo "  --cxx                Print the full path of the used cxx compiler"
      echo "  --fairsoft_path      Print the full path of the used fairsoft version"
      exit 0
      ;;
    *)
      ### Give an error
      echo "Unknown argument \"$1\"!" 1>&2
      echo "${usage}" 1>&2
      exit 1
      ;;
esac

### Output the stuff
echo $out
